﻿using System;
using Framework.CapaDeDatos;
using Framework.CapaDeDatos.Excepciones;
using Framework.CapaDeDatos.Proveedores;
using Framework.Modelo;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Rhino.Mocks;

namespace FrameworkTest.CapaDeDatosTest
{
    [TestClass()]
    public class ContenedorTest
    {
        private TestContext testContextInstance;

        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        [TestMethod()]
        public void ContenedorConstructorTestWithNull()
        {
            IProveedor proveedor = null;
            Contenedor target = null;
            try
            {
                target = new Contenedor(proveedor);
                Assert.Fail(Framework.Mensajes.CapaDeDatosTest.ContendorTest.ExcepcionParametroNuloExperada);
            }
            catch (Exception ex)
            {
                Assert.IsInstanceOfType(ex, typeof(ExceptionParametroNulo));
            }
        }

        [TestMethod()]
        public void ContenedorConstructorTestWithInstance()
        {
            IProveedor proveedor = MockRepository.GenerateStrictMock<IProveedor>();
            Contenedor target = new Contenedor(proveedor);
            Assert.IsNotNull(target);
            Assert.IsInstanceOfType(target, typeof(IContenedor));
        }

        [TestMethod()]
        public void RecuperarTest()
        {
            Guid guid = new Guid();
            IProveedor proveedor = MockRepository.GenerateStrictMock<IProveedor>();
            proveedor.Expect( s => s.Recuperar( guid ) ).Repeat.Once();
            Contenedor target = new Contenedor( proveedor ); // TODO: Initialize to an appropriate value
            IObjeto actual;
            actual = target.Recuperar( guid );
            Assert.IsInstanceOfType( actual, typeof( IObjeto ) );
        }

        [TestMethod()]
        public void GuardarTest()
        {
            IObjeto objeto = MockRepository.GenerateStrictMock<IObjeto>();
            IProveedor proveedor = MockRepository.GenerateStrictMock<IProveedor>();
            proveedor.Expect( s => s.Guardar( objeto ) ).Repeat.Once();
            Contenedor target = new Contenedor( proveedor ); // TODO: Initialize to an appropriate value
            IObjeto actual;
            actual = target.Guardar( objeto );
            Assert.IsInstanceOfType( actual, typeof( IObjeto ) );
        }
    }
}
